//
// Created by sgyt on 2020/3/7.
// 当接收到屏蔽信号

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>

static void sig_int(int signo){
    printf("signo is [%d]\n",signo);
}
int main(int argc,char *argv[])
{
    sigset_t newset,waitset,oldset;

    //注册信号
    signal(SIGINT,sig_int);

    sigemptyset(&newset);
    sigaddset(&newset,SIGINT);

    sigemptyset(&waitset);
    sigaddset(&waitset,SIGUSR1);

    //阻塞信号SIGINT
    sigprocmask(SIG_BLOCK,&newset,&oldset);

    printf("init is ok\n");

    sigsuspend(&waitset);

    printf("after return \n");

    sigprocmask(SIG_SETMASK,&oldset,NULL);

    printf("process is exit\n");
    return 0;
}